<?php
    $campo      =   $_GET['campo'];
    $relacao    =   $_GET['relacao'];
    $valor      =   $_GET['valor'];
    if($valor != ""){
        $cor_titulo = "#00cc99";
        $cor_linha1 = "white";
        $cor_linha2 = "#ccff66";
        include_once '../../SQL/connector.php';
        $con = new connector();
        if($relacao == "LIKE"){
            $valor = "%".$valor."%";
        }
        $query ="SELECT 
                    p.idPessoa, 
                    p.nome, 
                    p.cpf, 
                    p.data_nascimento
                FROM Pessoa AS p
                WHERE p.".$campo." ".$relacao." '".$valor."'
                ORDER BY p.nome ASC;";
        //echo $query;

        
        $result = $con->executaSql($query);
        echo "<table>";
        echo "<tr bgcolor=".$cor_titulo.">";
        echo "<th>ID</th>";
        echo "<th width='350' >NOME</th>";
        echo "<th>CPF</th>";
        echo "<th>DN</th>";
        echo "</tr>";
        $num=0;
        while($linha = mysql_fetch_row($result)){
            echo "<tr ";
            if($num <= 0){
                echo "bgcolor=".$cor_linha1;
                $num++;
            }else{
                echo "bgcolor=".$cor_linha2;
                $num--;
            }
            echo ">";
            echo "<td>".$linha[0]."</td>";
            echo "<td>";
            ?>
                <label onclick="javascript:carrega('conteudo', 'Paginas/Clientes/exibir.php?ExibirClienteID=<?php echo $linha[0];?>','<?php echo $linha[1];?>')"><?php echo $linha[1];?></label>
            <?php
            echo "</td>";
            echo "<td>".$linha[2]."</td>";
            echo "<td>";
                $data = explode("-",$linha[3]);
                echo $data[2]."-".$data[1]."-".$data[0];
            echo "</td>";
            echo "</tr>";
        }
    }
?>
